<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="utf-8" />
    
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1" />
  <title>
     Yolin
  </title>
  <meta name="generator" content="hexo-theme-yilia-plus">
  
  <link rel="shortcut icon" href="/favicon.png" />
  
  
<link rel="stylesheet" href="/css/style.css">

  
<script src="/js/pace.min.js"></script>


  

  

<link rel="alternate" href="/atom.xml" title="Yolin" type="application/atom+xml">
</head>

</html>

<body>
  <div id="app">
    <main class="content">
      
<section class="cover">
    
  <div class="cover-frame">
    <div class="bg-box">
      <img src="/images/cover2.jpg" alt="image frame" />
    </div>
    <div class="cover-inner text-center text-white">
      <h1><a href="/">Yolin</a></h1>
      <div id="subtitle-box">
        
        <span id="subtitle"></span>
        
      </div>
      <div>
        
      </div>
    </div>
  </div>
  <div class="cover-learn-more">
    <a href="javascript:void(0)" class="anchor"><i class="ri-arrow-down-line"></i></a>
  </div>
</section>



<script src="https://cdn.jsdelivr.net/npm/typed.js@2.0.11/lib/typed.min.js"></script>

<div id="main">
  <section class="outer">
  <article class="articles">
    
    
    
    
    <article id="post-Java-SE-修饰符" class="article article-type-post" itemscope
  itemprop="blogPost" data-scroll-reveal>

  <div class="article-inner">
    
    <header class="article-header">
       
<h2 itemprop="name">
  <a class="article-title" href="/2020/07/16/Java-SE-%E4%BF%AE%E9%A5%B0%E7%AC%A6/"
    >Java SE-修饰符</a
  >
</h2>
  

    </header>
    

    
    <div class="article-meta">
      <a href="/2020/07/16/Java-SE-%E4%BF%AE%E9%A5%B0%E7%AC%A6/" class="article-date">
  <time datetime="2020-07-16T12:50:02.000Z" itemprop="datePublished">2020-07-16</time>
</a>
      
  <div class="article-category">
    <a class="article-category-link" href="/categories/Java/">Java</a>
  </div>

      
      
      
    </div>
    

    

    <div class="article-entry" itemprop="articleBody">
      


      

      
      <h2 id="一、访问控制修饰符"><a href="#一、访问控制修饰符" class="headerlink" title="一、访问控制修饰符"></a>一、访问控制修饰符</h2><p><img src="https://yolin121.oss-cn-beijing.aliyuncs.com/blogimg/Snipaste_2020-07-15_10-34-00.jpg" alt=""></p>
<ol>
<li>一个源文件可以有多个类，但只能有一个public类如果有其他类只能以默认修饰。</li>
<li>声明属性和方法尽可能私有，这样才能做到尽可能的封装</li>
</ol>
<h2 id="二、常用的转义字符"><a href="#二、常用的转义字符" class="headerlink" title="二、常用的转义字符"></a>二、常用的转义字符</h2><figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br></pre></td><td class="code"><pre><span class="line"><span class="string">"\b"</span>  (退格)</span><br><span class="line"><span class="string">"\f"</span>  (换页)</span><br><span class="line"><span class="string">"\n"</span>  (换行)</span><br><span class="line"><span class="string">"\r"</span>  (回车)</span><br><span class="line"><span class="string">"\t"</span>  (水平制表符(到下一个tab位置))</span><br><span class="line"><span class="string">"\' "</span>  (单引号)</span><br><span class="line"><span class="string">"\" "</span>  (双引号)</span><br><span class="line"><span class="string">"\\"</span>  (反斜杠)</span><br></pre></td></tr></table></figure>
      
      <a class="article-more-link" href="/2020/07/16/Java-SE-%E4%BF%AE%E9%A5%B0%E7%AC%A6/">阅读更多...</a>
      
      
      <!-- reward -->
      
    </div>
      <!-- copyright -->
      
    <footer class="article-footer">
      
      
  <ul class="article-tag-list" itemprop="keywords"><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/abstract/" rel="tag">abstract</a></li><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/final/" rel="tag">final</a></li><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/static/" rel="tag">static</a></li></ul>


    </footer>

  </div>

  

  
  
  

  

</article>
    
    <article id="post-Java-SE-多态" class="article article-type-post" itemscope
  itemprop="blogPost" data-scroll-reveal>

  <div class="article-inner">
    
    <header class="article-header">
       
<h2 itemprop="name">
  <a class="article-title" href="/2020/07/15/Java-SE-%E5%A4%9A%E6%80%81/"
    >Java SE-多态</a
  >
</h2>
  

    </header>
    

    
    <div class="article-meta">
      <a href="/2020/07/15/Java-SE-%E5%A4%9A%E6%80%81/" class="article-date">
  <time datetime="2020-07-15T12:50:02.000Z" itemprop="datePublished">2020-07-15</time>
</a>
      
  <div class="article-category">
    <a class="article-category-link" href="/categories/Java/">Java</a>
  </div>

      
      
      
    </div>
    

    

    <div class="article-entry" itemprop="articleBody">
      


      

      
      <h2 id="一、引入概念"><a href="#一、引入概念" class="headerlink" title="一、引入概念"></a>一、引入概念</h2><p>在继承关系中，子类如果定义了一个与父类方法签名完全相同的方法，被称为<strong>覆写(Override)。</strong></p>
<p>学习继承的时候我们已经了解到引用变量的声明类型可能与其实际类型不符，例如下面的代码：</p>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">public</span> <span class="class"><span class="keyword">class</span> <span class="title">test</span> </span>&#123;</span><br><span class="line">    <span class="function"><span class="keyword">public</span> <span class="keyword">static</span> <span class="keyword">void</span> <span class="title">main</span><span class="params">(String[] args)</span> </span>&#123;</span><br><span class="line">        Person p = <span class="keyword">new</span> Student();</span><br><span class="line">        p.run(); <span class="comment">// 应该打印Person.run还是Student.run?</span></span><br><span class="line">    &#125;</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"><span class="class"><span class="keyword">class</span> <span class="title">Person</span> </span>&#123;</span><br><span class="line">    <span class="function"><span class="keyword">public</span> <span class="keyword">void</span> <span class="title">run</span><span class="params">()</span> </span>&#123;</span><br><span class="line">        System.out.println(<span class="string">"Person.run"</span>);</span><br><span class="line">    &#125;</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"><span class="class"><span class="keyword">class</span> <span class="title">Student</span> <span class="keyword">extends</span> <span class="title">Person</span> </span>&#123;</span><br><span class="line">    <span class="meta">@Override</span></span><br><span class="line">    <span class="function"><span class="keyword">public</span> <span class="keyword">void</span> <span class="title">run</span><span class="params">()</span> </span>&#123;</span><br><span class="line">        System.out.println(<span class="string">"Student.run"</span>);</span><br><span class="line">    &#125;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

<p>运行后我们发现实际上调用的方法是Student的run()方法。</p>
      
      <a class="article-more-link" href="/2020/07/15/Java-SE-%E5%A4%9A%E6%80%81/">阅读更多...</a>
      
      
      <!-- reward -->
      
    </div>
      <!-- copyright -->
      
    <footer class="article-footer">
      
      
  <ul class="article-tag-list" itemprop="keywords"><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/%E5%A4%9A%E6%80%81/" rel="tag">多态</a></li></ul>


    </footer>

  </div>

  

  
  
  

  

</article>
    
    <article id="post-Java-SE-继承" class="article article-type-post" itemscope
  itemprop="blogPost" data-scroll-reveal>

  <div class="article-inner">
    
    <header class="article-header">
       
<h2 itemprop="name">
  <a class="article-title" href="/2020/07/14/Java-SE-%E7%BB%A7%E6%89%BF/"
    >Java SE-继承</a
  >
</h2>
  

    </header>
    

    
    <div class="article-meta">
      <a href="/2020/07/14/Java-SE-%E7%BB%A7%E6%89%BF/" class="article-date">
  <time datetime="2020-07-14T12:50:02.000Z" itemprop="datePublished">2020-07-14</time>
</a>
      
  <div class="article-category">
    <a class="article-category-link" href="/categories/Java/">Java</a>
  </div>

      
      
      
    </div>
    

    

    <div class="article-entry" itemprop="articleBody">
      


      

      
      <h2 id="一、继承概述"><a href="#一、继承概述" class="headerlink" title="一、继承概述"></a>一、继承概述</h2><p>继承是面向对象三大特征之一，可以使得子类具有父类的属性和方法，还可以在子类中重新定义，追加属性和方法。</p>
<h3 id="继承格式"><a href="#继承格式" class="headerlink" title="继承格式"></a>继承格式</h3><ul>
<li>格式:<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">public</span> <span class="class"><span class="keyword">class</span> 子类名 <span class="keyword">extends</span> 父类名</span>&#123;&#125;</span><br></pre></td></tr></table></figure></li>
<li>父类也被称为<strong>基类、超类</strong></li>
<li>子类也被称为<strong>派生类</strong></li>
</ul>
<h3 id="继承演示"><a href="#继承演示" class="headerlink" title="继承演示"></a>继承演示</h3><h5 id="Fu-java"><a href="#Fu-java" class="headerlink" title="Fu.java"></a>Fu.java</h5><figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">public</span> <span class="class"><span class="keyword">class</span> <span class="title">Fu</span> </span>&#123;</span><br><span class="line">	<span class="function"><span class="keyword">public</span> <span class="keyword">void</span> <span class="title">fu_Method</span><span class="params">()</span></span>&#123;</span><br><span class="line">		System.out.println(<span class="string">"fu_method被调用"</span>);</span><br><span class="line">	&#125;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
      
      <a class="article-more-link" href="/2020/07/14/Java-SE-%E7%BB%A7%E6%89%BF/">阅读更多...</a>
      
      
      <!-- reward -->
      
    </div>
      <!-- copyright -->
      
    <footer class="article-footer">
      
      
  <ul class="article-tag-list" itemprop="keywords"><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/%E7%BB%A7%E6%89%BF/" rel="tag">继承</a></li></ul>


    </footer>

  </div>

  

  
  
  

  

</article>
    
    <article id="post-ArrayList练习-学生管理系统" class="article article-type-post" itemscope
  itemprop="blogPost" data-scroll-reveal>

  <div class="article-inner">
    
    <header class="article-header">
       
<h2 itemprop="name">
  <a class="article-title" href="/2020/07/13/ArrayList%E7%BB%83%E4%B9%A0-%E5%AD%A6%E7%94%9F%E7%AE%A1%E7%90%86%E7%B3%BB%E7%BB%9F/"
    >ArrayList练习-学生管理系统</a
  >
</h2>
  

    </header>
    

    
    <div class="article-meta">
      <a href="/2020/07/13/ArrayList%E7%BB%83%E4%B9%A0-%E5%AD%A6%E7%94%9F%E7%AE%A1%E7%90%86%E7%B3%BB%E7%BB%9F/" class="article-date">
  <time datetime="2020-07-13T14:50:02.000Z" itemprop="datePublished">2020-07-13</time>
</a>
      
  <div class="article-category">
    <a class="article-category-link" href="/categories/Java/">Java</a>
  </div>

      
      
      
    </div>
    

    

    <div class="article-entry" itemprop="articleBody">
      


      

      
      <p><img src="https://yolin121.oss-cn-beijing.aliyuncs.com/blogimg/demo2.gif" alt=""></p>
      
      <a class="article-more-link" href="/2020/07/13/ArrayList%E7%BB%83%E4%B9%A0-%E5%AD%A6%E7%94%9F%E7%AE%A1%E7%90%86%E7%B3%BB%E7%BB%9F/">阅读更多...</a>
      
      
      <!-- reward -->
      
    </div>
      <!-- copyright -->
      
    <footer class="article-footer">
      
      
  <ul class="article-tag-list" itemprop="keywords"><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/ArrayList/" rel="tag">ArrayList</a></li></ul>


    </footer>

  </div>

  

  
  
  

  

</article>
    
    <article id="post-Java-SE-集合-ArrayList" class="article article-type-post" itemscope
  itemprop="blogPost" data-scroll-reveal>

  <div class="article-inner">
    
    <header class="article-header">
       
<h2 itemprop="name">
  <a class="article-title" href="/2020/07/13/Java-SE-%E9%9B%86%E5%90%88-ArrayList/"
    >Java SE集合（ArrayList）</a
  >
</h2>
  

    </header>
    

    
    <div class="article-meta">
      <a href="/2020/07/13/Java-SE-%E9%9B%86%E5%90%88-ArrayList/" class="article-date">
  <time datetime="2020-07-13T05:50:02.000Z" itemprop="datePublished">2020-07-13</time>
</a>
      
  <div class="article-category">
    <a class="article-category-link" href="/categories/Java/">Java</a>
  </div>

      
      
      
    </div>
    

    

    <div class="article-entry" itemprop="articleBody">
      


      

      
      <h2 id="一、为什么引入集合"><a href="#一、为什么引入集合" class="headerlink" title="一、为什么引入集合"></a>一、为什么引入集合</h2><p>为了便于处理一组类似的数据</p>
<p>例如：</p>
<ul>
<li>计算所有同学的总成绩和平均成绩；</li>
<li>列举所有商品名称和价格；</li>
</ul>
<p>在Java中，如果一个Java对象可以在内部持有若干其他Java对象，并对外提供访问接口，我们把这种Java对象称为集合。显然，Java的数组可以看作是一种集合， <strong>但是</strong> ，由于数组的以下限制：</p>
<ul>
<li>数组初始化后大小不可变</li>
<li>数组只能按索引顺序存取</li>
</ul>
<p>因此我们需要各种不同类型的集合类来处理不同的数据</p>
<h2 id="二、集合概述"><a href="#二、集合概述" class="headerlink" title="二、集合概述"></a>二、集合概述</h2><p>集合类的特点：<strong>提供一种存储空间可变的存储模型，存储的数据容量可以发生改变。</strong></p>
<p>集合类有很多，本节我们先来认识<strong>ArrayList</strong></p>
      
      <a class="article-more-link" href="/2020/07/13/Java-SE-%E9%9B%86%E5%90%88-ArrayList/">阅读更多...</a>
      
      
      <!-- reward -->
      
    </div>
      <!-- copyright -->
      
    <footer class="article-footer">
      
      
  <ul class="article-tag-list" itemprop="keywords"><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/ArrayList/" rel="tag">ArrayList</a></li></ul>


    </footer>

  </div>

  

  
  
  

  

</article>
    
    <article id="post-Java-SE案例-String和StringBuilder" class="article article-type-post" itemscope
  itemprop="blogPost" data-scroll-reveal>

  <div class="article-inner">
    
    <header class="article-header">
       
<h2 itemprop="name">
  <a class="article-title" href="/2020/07/11/Java-SE%E6%A1%88%E4%BE%8B-String%E5%92%8CStringBuilder/"
    >Java SE案例（String与StringBuilder）</a
  >
</h2>
  

    </header>
    

    
    <div class="article-meta">
      <a href="/2020/07/11/Java-SE%E6%A1%88%E4%BE%8B-String%E5%92%8CStringBuilder/" class="article-date">
  <time datetime="2020-07-11T11:50:02.000Z" itemprop="datePublished">2020-07-11</time>
</a>
      
  <div class="article-category">
    <a class="article-category-link" href="/categories/Java/">Java</a>
  </div>

      
      
      
    </div>
    

    

    <div class="article-entry" itemprop="articleBody">
      


      

      
      <h2 id="一、String案例"><a href="#一、String案例" class="headerlink" title="一、String案例"></a>一、String案例</h2><h3 id="案例1-用户登录"><a href="#案例1-用户登录" class="headerlink" title="案例1.用户登录"></a>案例1.用户登录</h3><p>需求：已知用户名和密码，请用程序实现模拟用户登录。总共给三次机会，登陆之后，给出相应的提示</p>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">package</span> test;</span><br><span class="line"></span><br><span class="line"><span class="keyword">import</span> java.util.Scanner;</span><br><span class="line"></span><br><span class="line"><span class="keyword">public</span> <span class="class"><span class="keyword">class</span> <span class="title">denglu</span> </span>&#123;</span><br><span class="line">	<span class="function"><span class="keyword">public</span> <span class="keyword">static</span> <span class="keyword">void</span> <span class="title">main</span><span class="params">(String[] args)</span> </span>&#123;</span><br><span class="line">		String name=<span class="string">"yolin"</span>;</span><br><span class="line">		String password=<span class="string">"123456"</span>;</span><br><span class="line">		</span><br><span class="line">		Scanner s=<span class="keyword">new</span> Scanner(System.in);</span><br><span class="line">		</span><br><span class="line">		<span class="keyword">for</span>(<span class="keyword">int</span> i=<span class="number">3</span>;i&gt;=<span class="number">0</span>;i--)&#123;</span><br><span class="line">			System.out.println(<span class="string">"请输入账号"</span>);</span><br><span class="line">			String username=s.nextLine();</span><br><span class="line">			System.out.println(<span class="string">"请输入密码"</span>);</span><br><span class="line">			String userpassword=s.nextLine();</span><br><span class="line">			<span class="keyword">if</span>(name.equals(username)&amp;&amp;password.equals(userpassword))&#123;</span><br><span class="line">				System.out.println(<span class="string">"登陆成功"</span>);</span><br><span class="line">				<span class="keyword">break</span>;</span><br><span class="line">			&#125;<span class="keyword">else</span>&#123;</span><br><span class="line">				System.out.println(<span class="string">"账号或密码错误，请重新登陆，你还有"</span>+(i-<span class="number">1</span>)+<span class="string">"次机会"</span>);</span><br><span class="line">			&#125;</span><br><span class="line">		&#125;</span><br><span class="line">	&#125;</span><br><span class="line"></span><br><span class="line"></span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
      
      <a class="article-more-link" href="/2020/07/11/Java-SE%E6%A1%88%E4%BE%8B-String%E5%92%8CStringBuilder/">阅读更多...</a>
      
      
      <!-- reward -->
      
    </div>
      <!-- copyright -->
      
    <footer class="article-footer">
      
      
  <ul class="article-tag-list" itemprop="keywords"><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/String/" rel="tag">String</a></li><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/StringBuilder/" rel="tag">StringBuilder</a></li></ul>


    </footer>

  </div>

  

  
  
  

  

</article>
    
    <article id="post-Java-SE基础之面向对象-二" class="article article-type-post" itemscope
  itemprop="blogPost" data-scroll-reveal>

  <div class="article-inner">
    
    <header class="article-header">
       
<h2 itemprop="name">
  <a class="article-title" href="/2020/07/10/Java-SE%E5%9F%BA%E7%A1%80%E4%B9%8B%E9%9D%A2%E5%90%91%E5%AF%B9%E8%B1%A1-%E4%BA%8C/"
    >Java SE基础之面向对象(二)</a
  >
</h2>
  

    </header>
    

    
    <div class="article-meta">
      <a href="/2020/07/10/Java-SE%E5%9F%BA%E7%A1%80%E4%B9%8B%E9%9D%A2%E5%90%91%E5%AF%B9%E8%B1%A1-%E4%BA%8C/" class="article-date">
  <time datetime="2020-07-10T11:50:02.000Z" itemprop="datePublished">2020-07-10</time>
</a>
      
  <div class="article-category">
    <a class="article-category-link" href="/categories/Java/">Java</a>
  </div>

      
      
      
    </div>
    

    

    <div class="article-entry" itemprop="articleBody">
      


      

      
      <h2 id="一、this关键字"><a href="#一、this关键字" class="headerlink" title="一、this关键字"></a>一、this关键字</h2><p>①<strong>this修饰的变量用于指代成员变量</strong></p>
<ul>
<li>方法的形参如果与成员变量同名，不带this修饰的变量指的是形参，而不是成员变量</li>
<li>方法的形参没有与成员变量同名，不带this修饰的变量指的是成员变量</li>
</ul>
<p><img src="https://yolin121.oss-cn-beijing.aliyuncs.com/blogimg/Snipaste_2020-07-10_09-03-44.jpg" alt=""></p>
<p>②<strong>解决局部变量隐藏成员变量时</strong>，也就是局部变量与成员变量同名时</p>
<p>③<strong>this代表所在类的对象引用</strong></p>
      
      <a class="article-more-link" href="/2020/07/10/Java-SE%E5%9F%BA%E7%A1%80%E4%B9%8B%E9%9D%A2%E5%90%91%E5%AF%B9%E8%B1%A1-%E4%BA%8C/">阅读更多...</a>
      
      
      <!-- reward -->
      
    </div>
      <!-- copyright -->
      
    <footer class="article-footer">
      
      
  <ul class="article-tag-list" itemprop="keywords"><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/String/" rel="tag">String</a></li><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/this/" rel="tag">this</a></li><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/%E6%9E%84%E9%80%A0%E6%96%B9%E6%B3%95/" rel="tag">构造方法</a></li></ul>


    </footer>

  </div>

  

  
  
  

  

</article>
    
    <article id="post-Java-SE面向对象-一" class="article article-type-post" itemscope
  itemprop="blogPost" data-scroll-reveal>

  <div class="article-inner">
    
    <header class="article-header">
       
<h2 itemprop="name">
  <a class="article-title" href="/2020/07/09/Java-SE%E9%9D%A2%E5%90%91%E5%AF%B9%E8%B1%A1-%E4%B8%80/"
    >Java SE基础之面向对象(一)</a
  >
</h2>
  

    </header>
    

    
    <div class="article-meta">
      <a href="/2020/07/09/Java-SE%E9%9D%A2%E5%90%91%E5%AF%B9%E8%B1%A1-%E4%B8%80/" class="article-date">
  <time datetime="2020-07-09T13:50:02.000Z" itemprop="datePublished">2020-07-09</time>
</a>
      
  <div class="article-category">
    <a class="article-category-link" href="/categories/Java/">Java</a>
  </div>

      
      
      
    </div>
    

    

    <div class="article-entry" itemprop="articleBody">
      


      

      
      <h2 id="一、类"><a href="#一、类" class="headerlink" title="一、类"></a>一、类</h2><h4 id="什么是类"><a href="#什么是类" class="headerlink" title="什么是类"></a>什么是类</h4><p>类是对现实生活中一类具有个体属性和行为的事物的抽象，确定对象将会有的属性和行为</p>
<h4 id="类的组成"><a href="#类的组成" class="headerlink" title="类的组成"></a>类的组成</h4><ul>
<li><strong>属性</strong>：在类中通过<strong>成员变量</strong>来体现（类中方法外的变量）</li>
<li><strong>行为</strong>: 在类中通过<strong>成员方法</strong>体现（去掉static关键字）</li>
</ul>
<h4 id="类的定义"><a href="#类的定义" class="headerlink" title="类的定义"></a>类的定义</h4><p>步骤：</p>
<p>①<em>定义类</em></p>
<p>②<em>编写类的成员变量</em></p>
<p>③<em>编写类的成员方法</em></p>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">public</span> <span class="class"><span class="keyword">class</span> 类名</span>&#123;</span><br><span class="line">    <span class="comment">//成员变量</span></span><br><span class="line">    数据类型 变量<span class="number">1</span>;</span><br><span class="line">    </span><br><span class="line">    <span class="comment">//成员方法</span></span><br><span class="line">    方法<span class="number">1</span>;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
      
      <a class="article-more-link" href="/2020/07/09/Java-SE%E9%9D%A2%E5%90%91%E5%AF%B9%E8%B1%A1-%E4%B8%80/">阅读更多...</a>
      
      
      <!-- reward -->
      
    </div>
      <!-- copyright -->
      
    <footer class="article-footer">
      
      
  <ul class="article-tag-list" itemprop="keywords"><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/%E9%9D%A2%E5%90%91%E5%AF%B9%E8%B1%A1/" rel="tag">面向对象</a></li></ul>


    </footer>

  </div>

  

  
  
  

  

</article>
    
    <article id="post-Java-SE基础篇-七" class="article article-type-post" itemscope
  itemprop="blogPost" data-scroll-reveal>

  <div class="article-inner">
    
    <header class="article-header">
       
<h2 itemprop="name">
  <a class="article-title" href="/2020/07/07/Java-SE%E5%9F%BA%E7%A1%80%E7%AF%87-%E4%B8%83/"
    >Java SE基础篇(七)</a
  >
</h2>
  

    </header>
    

    
    <div class="article-meta">
      <a href="/2020/07/07/Java-SE%E5%9F%BA%E7%A1%80%E7%AF%87-%E4%B8%83/" class="article-date">
  <time datetime="2020-07-07T10:50:02.000Z" itemprop="datePublished">2020-07-07</time>
</a>
      
  <div class="article-category">
    <a class="article-category-link" href="/categories/Java/">Java</a>
  </div>

      
      
      
    </div>
    

    

    <div class="article-entry" itemprop="articleBody">
      


      

      
      <h2 id="一、方法概述"><a href="#一、方法概述" class="headerlink" title="一、方法概述"></a>一、方法概述</h2><p>方法是<strong>将具有独立功能的代码块组织成一个整体，使其具有特殊功能的代码集。</strong></p>
<p>注意：</p>
<ul>
<li>方法必须先创建才可以使用，该过程称为方法定义</li>
<li>方法创建后并不是直接运行的，需要手动使用后才能执行，该过程称为方法调用。</li>
</ul>
<h2 id="二、方法的定义与调用"><a href="#二、方法的定义与调用" class="headerlink" title="二、方法的定义与调用"></a>二、方法的定义与调用</h2><h3 id="①定义"><a href="#①定义" class="headerlink" title="①定义"></a>①定义</h3><figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">public</span> <span class="keyword">static</span> <span class="keyword">void</span> 方法名&#123;</span><br><span class="line">    <span class="comment">//方法体</span></span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

<h3 id="②调用"><a href="#②调用" class="headerlink" title="②调用"></a>②调用</h3><figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">方法名();</span><br></pre></td></tr></table></figure>

<p>举个栗子：</p>
<p><img src="https://yolin121.oss-cn-beijing.aliyuncs.com/blogimg/Snipaste_2020-07-07_12-48-09.jpg" alt=""></p>
      
      <a class="article-more-link" href="/2020/07/07/Java-SE%E5%9F%BA%E7%A1%80%E7%AF%87-%E4%B8%83/">阅读更多...</a>
      
      
      <!-- reward -->
      
    </div>
      <!-- copyright -->
      
    <footer class="article-footer">
      
      
  <ul class="article-tag-list" itemprop="keywords"><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/%E6%96%B9%E6%B3%95/" rel="tag">方法</a></li></ul>


    </footer>

  </div>

  

  
  
  

  

</article>
    
    <article id="post-Java-SE基础篇-六" class="article article-type-post" itemscope
  itemprop="blogPost" data-scroll-reveal>

  <div class="article-inner">
    
    <header class="article-header">
       
<h2 itemprop="name">
  <a class="article-title" href="/2020/07/06/Java-SE%E5%9F%BA%E7%A1%80%E7%AF%87-%E5%85%AD/"
    >Java SE基础篇(六)</a
  >
</h2>
  

    </header>
    

    
    <div class="article-meta">
      <a href="/2020/07/06/Java-SE%E5%9F%BA%E7%A1%80%E7%AF%87-%E5%85%AD/" class="article-date">
  <time datetime="2020-07-06T12:50:02.000Z" itemprop="datePublished">2020-07-06</time>
</a>
      
  <div class="article-category">
    <a class="article-category-link" href="/categories/Java/">Java</a>
  </div>

      
      
      
    </div>
    

    

    <div class="article-entry" itemprop="articleBody">
      


      

      
      <h2 id="一、什么是数组"><a href="#一、什么是数组" class="headerlink" title="一、什么是数组"></a>一、什么是数组</h2><p><strong>数组</strong>（array)是一种用于<strong>存储多个相同类型数据的存储模型</strong></p>
<h3 id="定义格式"><a href="#定义格式" class="headerlink" title="定义格式"></a>定义格式</h3><ul>
<li><strong>格式一</strong>： 数据类型 [ ] 变量名</li>
<li>范例： int [ ] arr</li>
<li>定义了一个int类型的数组，数组名是arr</li>
</ul>
<ul>
<li><strong>格式二</strong>：  数据类型 变量名 [ ]</li>
<li>范例： int arr[]</li>
<li>定义了一个int类型的变量，变量名是arr数组</li>
</ul>
<p>推荐使用格式一</p>
<h2 id="二、数组初始化"><a href="#二、数组初始化" class="headerlink" title="二、数组初始化"></a>二、数组初始化</h2><p>java中的数组必须先初始化，然后才能使用，所谓初始化是指为数组中的数组元素分配内存空间，并为每个数组元素赋值</p>
<h3 id="①动态初始化"><a href="#①动态初始化" class="headerlink" title="①动态初始化"></a>①动态初始化</h3>
      
      <a class="article-more-link" href="/2020/07/06/Java-SE%E5%9F%BA%E7%A1%80%E7%AF%87-%E5%85%AD/">阅读更多...</a>
      
      
      <!-- reward -->
      
    </div>
      <!-- copyright -->
      
    <footer class="article-footer">
      
      
  <ul class="article-tag-list" itemprop="keywords"><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/java%E5%86%85%E5%AD%98%E7%BB%93%E6%9E%84/" rel="tag">java内存结构</a></li><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/%E6%95%B0%E7%BB%84/" rel="tag">数组</a></li></ul>


    </footer>

  </div>

  

  
  
  

  

</article>
    
  </article>
  

  
  <nav class="page-nav">
    
    <a class="extend prev" rel="prev" href="/page/6/">上一页</a><a class="page-number" href="/">1</a><span class="space">&hellip;</span><a class="page-number" href="/page/5/">5</a><a class="page-number" href="/page/6/">6</a><span class="page-number current">7</span><a class="page-number" href="/page/8/">8</a><a class="page-number" href="/page/9/">9</a><a class="page-number" href="/page/10/">10</a><a class="extend next" rel="next" href="/page/8/">下一页</a>
  </nav>
  
</section>
</div>

      <footer class="footer">
  <div class="outer">
    <ul class="list-inline">
      <li>
        &copy;
        2020-2021
        张金
      </li>
      <li>
        
      </li>
    </ul>
    <ul class="list-inline">
      <li>
        
        
        <span>
  <i>PV:<span id="busuanzi_value_page_pv"></span></i>
  <i>UV:<span id="busuanzi_value_site_uv"></span></i>
</span>
        
      </li>
      <li>
        <!-- cnzz统计 -->
        
        <script type="text/javascript" src='https://s9.cnzz.com/z_stat.php?id=1278069914&amp;web_id=1278069914'></script>
        
        <img src="https://yolin121.oss-cn-beijing.aliyuncs.com/blogimg/beian.png">
        <a href="https://beian.miit.gov.cn"  style="color:#f72b07" target="_blank">陕ICP备20002449号</a>
      </li>

    </ul>
  </div>
</footer>
    <div class="to_top">
        <div class="totop" id="totop">
  <i class="ri-arrow-up-line"></i>
</div>
      </div>
    </main>
      <aside class="sidebar">
        <button class="navbar-toggle"></button>
<nav class="navbar">
  
  <div class="logo">
    <a href="/"><img src="/images/ayer-side.svg" alt="Yolin"></a>
  </div>
  
  <ul class="nav nav-main">
    
    <li class="nav-item">
      <a class="nav-item-link" href="/">主页</a>
    </li>
    
    <li class="nav-item">
      <a class="nav-item-link" href="/archives">归档</a>
    </li>
    
    <li class="nav-item">
      <a class="nav-item-link" href="/categories">分类</a>
    </li>
    
    <li class="nav-item">
      <a class="nav-item-link" href="/tags">标签</a>
    </li>
    
    <li class="nav-item">
      <a class="nav-item-link" href="/playlist">歌单</a>
    </li>
    
    <li class="nav-item">
      <a class="nav-item-link" href="/video">视频</a>
    </li>
    
    <li class="nav-item">
      <a class="nav-item-link" href="/about">关于我</a>
    </li>
    
    <li class="nav-item">
      <a class="nav-item-link" href="/friends">友情链接</a>
    </li>
    
  </ul>
</nav>
<nav class="navbar navbar-bottom">
  <ul class="nav">
    <li class="nav-item">
      
      <a class="nav-item-link nav-item-search"  title="Search">
        <i class="ri-search-line"></i>
      </a>
      
      
      <a class="nav-item-link" target="_blank" href="/atom.xml" title="RSS Feed">
        <i class="ri-rss-line"></i>
      </a>
      
    </li>
  </ul>
</nav>
<div class="search-form-wrap">
  <div class="local-search local-search-plugin">
  <input type="search" id="local-search-input" class="local-search-input" placeholder="Search...">
  <div id="local-search-result" class="local-search-result"></div>
</div>
</div>
      </aside>
      <div id="mask"></div>

<!-- #reward -->
<div id="reward">
  <span class="close"><i class="ri-close-line"></i></span>
  <p class="reward-p"><i class="ri-cup-line"></i>请我喝杯咖啡吧~</p>
  <div class="reward-box">
    
    <div class="reward-item">
      <img class="reward-img" src="/images/alipay.jpg">
      <span class="reward-type">支付宝</span>
    </div>
    
    
    <div class="reward-item">
      <img class="reward-img" src="/images/wechat.jpg">
      <span class="reward-type">微信</span>
    </div>
    
  </div>
</div>
      
<script src="/js/jquery-2.0.3.min.js"></script>


<script src="/js/jquery.justifiedGallery.min.js"></script>


<script src="/js/lazyload.min.js"></script>


<script src="/js/busuanzi-2.3.pure.min.js"></script>


<script src="/js/share.js"></script>




<script>
  try {
    var typed = new Typed("#subtitle", {
    strings: ['肠断月明红豆蔻,','月似当时,','人似当时否？'],
    startDelay: 1500,
    typeSpeed: 200,
    loop: true,
    backSpeed: 40,
    showCursor: true
    });
  } catch (err) {
  }
  
</script>




<script>
  var ayerConfig = {
    mathjax: true
  }
</script>


<script src="/js/ayer.js"></script>


<script src="https://cdn.jsdelivr.net/npm/jquery-modal@0.9.2/jquery.modal.min.js"></script>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/jquery-modal@0.9.2/jquery.modal.min.css">


<!-- Root element of PhotoSwipe. Must have class pswp. -->
<div class="pswp" tabindex="-1" role="dialog" aria-hidden="true">

    <!-- Background of PhotoSwipe. 
         It's a separate element as animating opacity is faster than rgba(). -->
    <div class="pswp__bg"></div>

    <!-- Slides wrapper with overflow:hidden. -->
    <div class="pswp__scroll-wrap">

        <!-- Container that holds slides. 
            PhotoSwipe keeps only 3 of them in the DOM to save memory.
            Don't modify these 3 pswp__item elements, data is added later on. -->
        <div class="pswp__container">
            <div class="pswp__item"></div>
            <div class="pswp__item"></div>
            <div class="pswp__item"></div>
        </div>

        <!-- Default (PhotoSwipeUI_Default) interface on top of sliding area. Can be changed. -->
        <div class="pswp__ui pswp__ui--hidden">

            <div class="pswp__top-bar">

                <!--  Controls are self-explanatory. Order can be changed. -->

                <div class="pswp__counter"></div>

                <button class="pswp__button pswp__button--close" title="Close (Esc)"></button>

                <button class="pswp__button pswp__button--share" style="display:none" title="Share"></button>

                <button class="pswp__button pswp__button--fs" title="Toggle fullscreen"></button>

                <button class="pswp__button pswp__button--zoom" title="Zoom in/out"></button>

                <!-- Preloader demo http://codepen.io/dimsemenov/pen/yyBWoR -->
                <!-- element will get class pswp__preloader--active when preloader is running -->
                <div class="pswp__preloader">
                    <div class="pswp__preloader__icn">
                        <div class="pswp__preloader__cut">
                            <div class="pswp__preloader__donut"></div>
                        </div>
                    </div>
                </div>
            </div>

            <div class="pswp__share-modal pswp__share-modal--hidden pswp__single-tap">
                <div class="pswp__share-tooltip"></div>
            </div>

            <button class="pswp__button pswp__button--arrow--left" title="Previous (arrow left)">
            </button>

            <button class="pswp__button pswp__button--arrow--right" title="Next (arrow right)">
            </button>

            <div class="pswp__caption">
                <div class="pswp__caption__center"></div>
            </div>

        </div>

    </div>

</div>

<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/photoswipe@4.1.3/dist/photoswipe.min.css">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/photoswipe@4.1.3/dist/default-skin/default-skin.css">
<script src="https://cdn.jsdelivr.net/npm/photoswipe@4.1.3/dist/photoswipe.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/photoswipe@4.1.3/dist/photoswipe-ui-default.min.js"></script>

<script>
    function viewer_init() {
        let pswpElement = document.querySelectorAll('.pswp')[0];
        let $imgArr = document.querySelectorAll(('.article-entry img:not(.reward-img)'))

        $imgArr.forEach(($em, i) => {
            $em.onclick = () => {
                // slider展开状态
                // todo: 这样不好，后面改成状态
                if (document.querySelector('.left-col.show')) return
                let items = []
                $imgArr.forEach(($em2, i2) => {
                    let img = $em2.getAttribute('data-idx', i2)
                    let src = $em2.getAttribute('data-target') || $em2.getAttribute('src')
                    let title = $em2.getAttribute('alt')
                    // 获得原图尺寸
                    const image = new Image()
                    image.src = src
                    items.push({
                        src: src,
                        w: image.width || $em2.width,
                        h: image.height || $em2.height,
                        title: title
                    })
                })
                var gallery = new PhotoSwipe(pswpElement, PhotoSwipeUI_Default, items, {
                    index: parseInt(i)
                });
                gallery.init()
            }
        })
    }
    viewer_init()
</script>



<script type="text/x-mathjax-config">
  MathJax.Hub.Config({
      tex2jax: {
          inlineMath: [ ['$','$'], ["\\(","\\)"]  ],
          processEscapes: true,
          skipTags: ['script', 'noscript', 'style', 'textarea', 'pre', 'code']
      }
  });

  MathJax.Hub.Queue(function() {
      var all = MathJax.Hub.getAllJax(), i;
      for(i=0; i < all.length; i += 1) {
          all[i].SourceElement().parentNode.className += ' has-jax';
      }
  });
</script>

<script src="https://cdn.jsdelivr.net/npm/mathjax@2.7.6/unpacked/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>


<script type="text/javascript" src="https://js.users.51.la/20544303.js"></script>
  </div>
</body>

</html>